package xyz.bali16.module.netdisk.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import xyz.bali16.application.core.enums.ApiEnum;
import xyz.bali16.application.core.model.Result;
import xyz.bali16.module.netdisk.entity.UploadFile;
import xyz.bali16.module.netdisk.model.file.UploadFileAddParam;
import xyz.bali16.module.netdisk.model.file.UploadFilePageParam;
import xyz.bali16.module.netdisk.model.file.UploadFileUpdateParam;


import javax.validation.Valid;

import static xyz.bali16.application.core.model.Result.*;

/***
 * 约定: 父目录是自己的id就意味着自己是根目录
 */


@RestController
@RequestMapping(BaseController.API+"uploadfile")
public class UploadFileController extends NetdiskBaseController {

    @GetMapping
    @ApiOperation("文件列表数据")
    //@RequiresPermissions("netdisk:uploadFile:query")
    public Result<IPage<UploadFile>> list(UploadFilePageParam param) {
        IPage<UploadFile> uploadFileIPage = uploadFileService.getPage(param);
        return success(ApiEnum.GET_SUCCESS, uploadFileIPage);
    }

    //@PostMapping
    //@ApiOperation("添加文件")
    //public Result<String> add(@RequestBody @Valid UploadFileAddParam param) {
    //    try {
    //        uploadFileService.add(param);
    //        return response(ApiEnum.ADD_SUCCESS);
    //    } catch (Exception e) {
    //        return failure(ApiEnum.ADD_ERROR, "新增文件用户失败", e);
    //    }
    //}
    //
    //@PutMapping
    //@ApiOperation("修改文件")
    //public Result<String> update(@RequestBody @Valid UploadFileUpdateParam param) {
    //    try {
    //        uploadFileService.update(param);
    //        return response(ApiEnum.UPDATE_SUCCESS);
    //    } catch (Exception e) {
    //        return failure(ApiEnum.UPDATE_ERROR, "更新标签失败", e);
    //    }
    //}
    //
    //
    //@DeleteMapping("/{uploadFileId}")
    //@ApiOperation("删除文件目录")
    //@ApiImplicitParam(name = "uploadFileId", value = "文件目录id", paramType = "path", required = true)
    //public Result<String> delete(@PathVariable("uploadFileId") String uploadFileId) {
    //    try {
    //        uploadFileService.delete(uploadFileId);
    //        return response(ApiEnum.DELETE_SUCCESS);
    //    } catch (Exception e) {
    //        return failure(ApiEnum.DELETE_ERROR, e);
    //    }
    //}
}
